package org.lq.his.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.lq.his.dao.PermissionDao;
import org.lq.his.pojo.Permission;
import org.lq.his.service.PermissionService;
import org.springframework.stereotype.Service;

@Service("permissionService")
public class PermissionServiceImpl implements PermissionService{

	
	@Resource
	private PermissionDao permissionDao;
	
	public void setPermissionDao(PermissionDao permissionDao) {
		this.permissionDao = permissionDao;
	}

	@Override
	public List<Permission> getAll() {
		
		return permissionDao.getAll();
	}

	@Override
	public void deletePermissionsById(Integer id) {
		
		permissionDao.deletePermissionsById(id);
	}
	
	@Override
	public Permission getById(Integer id) {
		
		return permissionDao.getById(id);
	}
	
	//根据角色编号查询拥有的权限编号
	@Override
	public List<Integer> getPermissionIdsByRoleId(Integer roleId) {

		return permissionDao.getPermissionIdsByRoleId(roleId);
	}
	//删除权限
	@Override
	public void deletePermissionsByRoleId(Integer roleId) {

		permissionDao.deletePermissionsByRoleId(roleId);
	}
	// 批量添加权限
	@Override
	public void addRolePermissions(Integer roleId, List<Integer> perIds) {

		permissionDao.addRolePermissions(roleId, perIds);
	}

	//查询用户拥有的所有的功能编号
	@Override
	public List<String> getPermissionCodeByUserId(Integer userid) {
		
		return permissionDao.getPermissionCodeByUserId(userid);
	}

	@Override
	public void add(Permission permission) {
		
		permissionDao.add(permission);
	}

	@Override
	public void update(Permission permission) {
		
		permissionDao.update(permission);
	}

	@Override
	public List<Permission> getPermissionId(Integer id) {

		return permissionDao.getPermissionId(id);
	}
}
